package com.mg.yygh.common.utils;

import com.mg.yygh.common.helper.JwtHelper;

import javax.net.ssl.HttpsURLConnection;
import javax.servlet.http.HttpServletRequest;

/**
 * @author M_Dragon
 * @date 2022/9/19/019 11:33
 */
public class AuthContextHolder {

    // 获取当前用户id
    public static Long getUserId(HttpServletRequest request){
        // 通过header获取token
        String token = request.getHeader("token");
        // 通过token获取userid
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }
    // 获取当前用户名称
    public static String getUserName(HttpServletRequest request){
        // 通过header获取token
        String token = request.getHeader("token");
        // 通过token获取userName
        String userName = JwtHelper.getUserName(token);
        return userName;
    }

}
